import tensorflow as tf

a = tf.constant(2)
b = tf.constant(3)

# one way
with tf.Session() as sess:
    print("a = 2, b = 3")
    print("Addition with constants: %i" % sess.run(a + b))
    print("Multiplication with constants: %i" % sess.run(a * b))

a = tf.placeholder(tf.int16)
b = tf.placeholder(tf.int16)
add = tf.add(a, b)
mul = tf.multiply(a, b)

# the second
with tf.Session() as sess:
    print("Addition with constants: %i" % sess.run(add, feed_dict={a: 2, b: 3}))
    print("Multiplication with variables: %i" % sess.run(mul, feed_dict={a: 2, b: 3}))

# 矩阵相乘
matrix1 = tf.constant([[3, 3, 4]])
matrix2 = tf.constant([[2], [2], [5]])
product = tf.matmul(matrix1, matrix2)
with tf.Session() as sess:
    result = sess.run(product)
    print(result)